﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HROReporting.Infrastructure.Domain;

namespace HROReporting.Model.Studenten
{
    public class Student : EntityBase<int>, IAggregateRoot
    {
        public Student()
        {
            Reserveringen = new List<Reservering>();
        }

        public string IdentityToken { get; set; }
        public string Email { get; set; }
        public string Studentnummer { get; set; }
        public ICollection<Reservering> Reserveringen { get; set; }

        protected override void Validate()
        {
            if (String.IsNullOrEmpty(IdentityToken))
            {
                base.AddBrokenRule(StudentBusinessRules.IdentityTokenRequired);
            }

            if (!new EmailValidationSpecification().IsSatisfiedBy(Email))
            {
                base.AddBrokenRule(StudentBusinessRules.EmailRequired);
            }

            if (String.IsNullOrEmpty(Studentnummer))
            {
                base.AddBrokenRule(StudentBusinessRules.StudentnummerRequired);
            }
        }
    }
}
